package first.endtoend.gcm;

import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;

import java.io.IOException;

/**
 * Created by ncordina on 25/06/2015.
 */
public class GCMServer
{
    private String apiKey;
    private Sender sender;
    private String registrationID;
    private int numOfRetries;

    /**
     * @param apiKey
     * @param registrationID
     * @param numOfRetries
     */
    public GCMServer(String apiKey, String registrationID, int numOfRetries)
    {
        this.apiKey = apiKey;
        this.registrationID = registrationID;
        this.numOfRetries = numOfRetries;
        sender = new Sender(apiKey);
    }

    /**
     * @param message
     * @throws IOException
     */
    public void sendMessage(Message message) throws IOException
    {
        Result result = sender.send(message, registrationID, numOfRetries);
    }

}
